<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/ad_fragments :: head(~{::title})">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分类管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
</head>

<body>
<!--导航-->
<nav th:replace="admin/ad_fragments :: menu(2)" class="ui inverted attached segment"></nav>
<!--二级导航-->
<div class="ui inverted attached pointing menu">
    <div class="ui container">
        <div id="sidebar-btn" class="ui inverted labeled icon button">
            <i class="sidebar icon"></i>点我
        </div>
        <div class="right menu">
            <a href="#" th:href="@{/admin/types}" class="item" style="color: #ffcbf0;"><i class="list icon"></i>列表</a>
            <a href="#" th:href="@{/admin/types/input}" class="active item" style="color: #ffcbf0;"><i
                    class="edit icon"></i>新增</a>
        </div>
    </div>
</div>
<!--中间内容-->
<div class="m-container m-padded-tb-big">
    <div class="ui container">
        <form id="type-form" action="#" th:action="${type.id}==null ? @{/admin/types} : @{/admin/types/{id}(id=${type.id})}"
              method="post" class="ui form">
            <input type="hidden" name="id" th:value="${type.id}">
            <div class="field">
                <div class="ui left labeled input">
                    <label class="ui teal basic label">名称</label>
                    <input type="text" name="name" placeholder="分类名称" th:value="${type.name}">
                </div>
            </div>
            <div class="ui error message"></div>
            <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                <i class="close icon"></i>
                <div class="header">提示：</div>
                <p th:text="${message}">恭喜，操作成功！</p>
            </div>
            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="button" id="publish-btn" class="ui secondary submit button">提交</button>
            </div>
        </form>
    </div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


<!--/*/<th:block th:replace="admin/ad_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js"></script>
<!--/*/</th:block>/*/-->
<!--利用jQuery获取到菜单-->
<script>

    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
    $("#sidebar-btn").click(function () {
        $(".ui.sidebar")
            .sidebar({
                transition: 'scale down' //默认uncover，可以取值push\overlay\slide along\slide out\scale down
            })
            .sidebar("toggle")
    });
    $('.ui.dropdown')
        .dropdown()
    ;
    $('.message .close')
        .on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade')
            ;
        })
    ;

    $('#publish-btn').click(function () {
        $('[name="published"]').val(true);
        $('#type-form').submit();
    });

    //标题为空，提示错误
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'name',
                rules: [{
                    type: 'empty',
                    prompt: '请输入分类名称'
                }]
            }
        }
    })
</script>
</body>
</html>